package com.dnjn.happiness.auth.api.factory;

import com.dnjn.happiness.auth.api.RemoteAuthService;
import com.dnjn.happiness.common.core.domain.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class RemoteAuthFallbackFactory implements FallbackFactory<RemoteAuthService>{
    private static final Logger log = LoggerFactory.getLogger(RemoteAuthService.class);

    @Override
    public RemoteAuthService create(Throwable throwable) {
        log.error("调用auth服务失败: " + throwable.getMessage());
        return new RemoteAuthService() {
            @Override
            public R<Boolean> validLinkedUrlApi(String host, String source) {
                return R.fail("校验URL失败: {}" + throwable.getMessage());
            }
        } ;
    }
}
